38 #include "fsl_debug_console.h" 46 #ifndef F_USE_WIRELESS_UART 47 #define F_USE_WIRELESS_UART 0x0001 49 #ifndef F_USE_WIRED_UART 50 #define F_USE_WIRED_UART 0x0002 53 #define CONTROL_BAUDRATE 115200 73 flag = base->S1 & 0x80;
75 UART_WriteByte(base, data);
82 for (i = 0; i < nbytes; i++)
87 #if F_USE_WIRELESS_UART 95 #if F_USE_WIRELESS_UART 102 for (i = 0; i < nbytes; i++)
116 static char iCommandBuffer_B[5] =
"~~~~";
118 flags = UART_GetStatusFlags(WIRELESS_UART);
120 if ((kUART_RxDataRegFullFlag | kUART_RxOverrunFlag) & flags)
123 if (sts == kStatus_Success)
125 data = UART_ReadByte(WIRELESS_UART);
152 if (kUART_TxDataRegEmptyFlag & UART_GetStatusFlags(WIRED_UART))
154 UART_WriteByte(WIRED_UART, data);
164 static char iCommandBuffer_A[5] =
"~~~~";
167 flags = UART_GetStatusFlags(WIRED_UART);
169 if ((kUART_RxDataRegFullFlag | kUART_RxOverrunFlag) & flags)
172 if (sts == kStatus_Success)
174 data = UART_ReadByte(WIRED_UART);
186 uart_config_t config;
201 CLOCK_EnableClock(WIRED_UART_PORT_CLKEN);
202 PORT_SetPinMux(WIRED_UART_PORT, WIRED_UART_RX_PIN, WIRED_UART_MUX);
203 PORT_SetPinMux(WIRED_UART_PORT, WIRED_UART_TX_PIN, WIRED_UART_MUX);
204 UART_GetDefaultConfig(&config);
207 config.enableTx =
true;
208 config.enableRx =
true;
209 config.rxFifoWatermark = 1;
210 UART_Init(WIRED_UART, &config, CLOCK_GetFreq(WIRED_UART_CLKSRC));
213 UART_EnableInterrupts(WIRED_UART, kUART_RxDataRegFullInterruptEnable |
214 kUART_RxOverrunInterruptEnable);
215 EnableIRQ(WIRED_UART_IRQn);
217 #if F_USE_WIRELESS_UART 219 CLOCK_EnableClock(WIRELESS_UART_PORT_CLKEN);
220 PORT_SetPinMux(WIRELESS_UART_PORT, WIRELESS_UART_RX_PIN,
222 PORT_SetPinMux(WIRELESS_UART_PORT, WIRELESS_UART_TX_PIN,
225 UART_Init(WIRELESS_UART, &config, CLOCK_GetFreq(WIRELESS_UART_CLKSRC));
229 UART_EnableInterrupts(WIRELESS_UART, kUART_RxDataRegFullInterruptEnable |
230 kUART_RxOverrunInterruptEnable);
231 EnableIRQ(WIRELESS_UART_IRQn);
void WIRED_UART_IRQHandler(void)
int8_t writeWirelessPort(uint8_t buffer[], uint16_t nbytes)
Receiving commands over wireless interface (momentary)
volatile uint8_t AltPacketOn
flag to enable altitude packet
The top level fusion structure.
streamData_t * stream
function to create packets for serial stream
volatile int8_t AccelCalPacketOn
variable used to coordinate accelerometer calibration
quaternion_type DefaultQuaternionPacketType
default quaternion transmitted at power on
uart_handle_t wired_uartHandle
void myUART_WriteByte(UART_Type *base, uint8_t data)
int8_t writeControlPort(ControlSubsystem *pComm, uint8_t buffer[], uint16_t nbytes)
void CreateAndSendPackets(SensorFusionGlobals *sfg, uint8_t *sUARTOutputBuffer)
Called once per fusion cycle to stream information required by the NXP Sensor Fusion Toolbox...
The sensor_fusion.h file implements the top level programming interface.
Receiving commands over wired interface (momentary)
he ControlSubsystem encapsulates command and data streaming functions.
uint8_t sUARTOutputBuffer[256]
main output buffer defined in control.c
volatile uint8_t DebugPacketOn
flag to enable debug packet
writePort_t * write
low level function to write a char buffer to the serial stream
int8_t initializeControlPort(ControlSubsystem *pComm)
Initialize the control subsystem and all related hardware.
void DecodeCommandBytes(SensorFusionGlobals *sfg, char iCommandBuffer[], uint8 sUART_InputBuffer[], uint16 nbytes)
This function is responsible for decoding commands sent by the NXP Sensor Fusion Toolbox and setting ...
void BlueRadios_Init(void)
Used to initialize the Blue Radios Bluetooth module found on the FRDM-FXS-MULT2-B sensor shield from ...
uart_handle_t wireless_uartHandle
volatile uint8_t RPCPacketOn
flag to enable roll, pitch, compass packet
Quaternion derived from 3-axis accel (tilt)
Defines control sub-system.
setStatus_t * setStatus
change status indicator immediately
SensorFusionGlobals sfg
This is the primary sensor fusion data structure.
#define CONTROL_BAUDRATE
Baudrate to be used for serial communications.
volatile quaternion_type QuaternionPacketType
quaternion type transmitted over UART
void WIRELESS_UART_IRQHandler(void)
volatile uint8_t AngularVelocityPacketOn
flag to enable angular velocity packet